package redis

func (k *key) SAdd(member ...any) IntResult {
	args := []any{k.key}
	for _, v := range member {
		args = append(args, v)
	}
	return k.cmd("SADD", args...)
}

func (k *key) SIsMember(member any) BoolResult {
	return k.cmd("SISMEMBER", k.key, member)
}

func (k *key) SMIsMember(member ...any) IntListResult {
	return k.cmd("SMISMEMBER", append([]any{k.key}, member...)...)
}

func (k *key) SPop() ValueResult {
	return k.cmd("SPOP", k.key)
}

func (k *key) SRandMember(count ...int) ValueResult {
	if len(count) > 0 {
		return k.cmd("SRANDMEMBER", k.key, count[0])
	}
	return k.cmd("SRANDMEMBER", k.key)
}

func (k *key) SRem(member ...any) IntResult {
	return k.cmd("SREM", append([]any{k.key}, member...)...)
}

func (k *key) SMove(member any) BoolResult {
	var args []any
	for _, k := range k.keys {
		args = append(args, k)
	}
	args = append(args, member)
	return k.cmd("SMOVE", args...)
}

func (k *key) SCard() IntResult {
	return k.cmd("SCARD", k.key)
}

func (k *key) SMembers() ListResult {
	return k.cmd("SMEMBERS", k.key)
}

func (k *key) SInter() ListResult {
	var args []any
	for _, k := range k.keys {
		args = append(args, k)
	}
	return k.cmd("SINTER", args...)
}

func (k *key) SInterStore() IntResult {
	var args []any
	for _, k := range k.keys {
		args = append(args, k)
	}
	return k.cmd("SINTERSTORE", args...)
}

func (k *key) SUnion() ListResult {
	var args []any
	for _, k := range k.keys {
		args = append(args, k)
	}
	return k.cmd("SUNION", args...)
}

func (k *key) SUnionStore() IntResult {
	var args []any
	for _, k := range k.keys {
		args = append(args, k)
	}
	return k.cmd("SUNIONSTORE", args...)
}

func (k *key) SDiff() ListResult {
	var args []any
	for _, k := range k.keys {
		args = append(args, k)
	}
	return k.cmd("SDIFF", args...)
}

func (k *key) SDiffStore() IntResult {
	var args []any
	for _, k := range k.keys {
		args = append(args, k)
	}
	return k.cmd("SDIFFSTORE", args...)
}

func (k *key) SScan(args *ScanArgs) error {
	return k.scan("SSCAN", args)
}
